package com.stockz.indicator.vsa;

import java.util.List;

import com.stockz.core.model.Bar;
import com.stockz.core.util.BarUtil.BarValueType;
import com.stockz.indicator.Indicator;
import com.stockz.indicator.movingAverage.simple.SimpleMovingAverageIndicator;
import com.stockz.indicator.stochastics.StochasticsIndicator;
import com.stockz.indicator.vsa.analyzer.VsaPatternAnalyzer;
import com.stockz.indicator.vsa.analyzer.VsaPropertyAnalyzer;

public class VsaIndicator implements Indicator<VsaIndicatorConfiguration> {

	private VsaIndicatorConfiguration vsaIndicatorConfiguration;
	private SimpleMovingAverageIndicator simpleMovingAverageIndicator;
	private StochasticsIndicator stochasticsIndicator;
	private BarValueType barValueType = BarValueType.AVGPRICE;
	
	public VsaIndicator(
			SimpleMovingAverageIndicator simpleMovingAverageIndicator,
			StochasticsIndicator stochasticsIndicator) {
		super();
		this.simpleMovingAverageIndicator = simpleMovingAverageIndicator;
		this.stochasticsIndicator = stochasticsIndicator;
		
		vsaIndicatorConfiguration
		 = new VsaIndicatorConfiguration(simpleMovingAverageIndicator.getIndicatorConfiguration(),
				 stochasticsIndicator.getIndicatorConfiguration());
	}

	public List<VsaBar> convert(List<Bar> barList){
		VsaPropertyAnalyzer vsaPropertyAnalyzer = 
			new VsaPropertyAnalyzer(simpleMovingAverageIndicator,stochasticsIndicator);
		VsaPatternAnalyzer vsaPatternAnalyzer = new VsaPatternAnalyzer();

		return vsaPatternAnalyzer.analyze(barList,
				vsaPropertyAnalyzer.analyze(barList));
	}
	
	@Override
	public VsaIndicatorConfiguration getIndicatorConfiguration() {
		return vsaIndicatorConfiguration;
	}

	@Override
	public double getValue(List<Bar> barList) {
		throw new UnsupportedOperationException();
	}

	
	@Override
	public double[] getValues(List<Bar> barList) {
		throw new UnsupportedOperationException();
	}

	public BarValueType getBarValueType() {
		return barValueType;
	}

	public void setBarValueType(BarValueType barValueType) {
		this.barValueType = barValueType;
	}
}


